﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
  
  <head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-39155502-5"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
  
      gtag('config', 'UA-39155502-5');
    </script>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Class DB
   | MongoDB.Entities </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Class DB
   | MongoDB.Entities ">
    <meta name="generator" content="docfx 2.58.4.0">
    <meta name="description" content="A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management.">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">
    
    <meta property="docfx:rel" content="../">
    <meta property="docfx:newtab" content="true">
    <meta property="og:title" content="MongoDB.Entities">
    <meta property="og:site_name" content="MongoDB.Entities">
    <meta property="og:url" content="https://mongodb-entities.com">
    <meta property="og:description" content="A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management,">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://mongodb-entities.com/images/social-square.png">  
  </head>
  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>
        
        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              
              <a class="navbar-brand" href="../index.html">
                <img id="logo" class="svg" src="../images/icon.png" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
            </div>
          </div>
        </nav>
        
        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div class="container body-content">
        
        <div id="search-results">
          <div class="search-list">Search Results for <span></span></div>
          <div class="sr-items">
            <p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
          </div>
          <ul id="pagination" data-first="First" data-prev="Previous" data-next="Next" data-last="Last"></ul>
        </div>
      </div>
      <div role="main" class="container body-content hide-when-search">
        
        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div id="sidetoc"></div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="MongoDB.Entities.DB">
  
  
  <h1 id="MongoDB_Entities_DB" data-uid="MongoDB.Entities.DB" class="text-break">Class DB
  </h1>
  <div class="markdown level0 summary"><p>The main entrypoint for all data access methods of the library</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><span class="xref">System.Object</span></div>
    <div class="level1"><span class="xref">DB</span></div>
  </div>
  <div class="inheritedMembers">
    <h5>Inherited Members</h5>
    <div>
      <span class="xref">System.Object.Equals(System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.Equals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.GetHashCode()</span>
    </div>
    <div>
      <span class="xref">System.Object.GetType()</span>
    </div>
    <div>
      <span class="xref">System.Object.MemberwiseClone()</span>
    </div>
    <div>
      <span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
    </div>
    <div>
      <span class="xref">System.Object.ToString()</span>
    </div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="MongoDB.Entities.html">MongoDB.Entities</a></h6>
  <h6><strong>Assembly</strong>: MongoDB.Entities.dll</h6>
  <h5 id="MongoDB_Entities_DB_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static class DB</code></pre>
  </div>
  <h3 id="methods">Methods
  </h3>
  
  
  <a id="MongoDB_Entities_DB_AllDatabaseNamesAsync_" data-uid="MongoDB.Entities.DB.AllDatabaseNamesAsync*"></a>
  <h4 id="MongoDB_Entities_DB_AllDatabaseNamesAsync_MongoDB_Driver_MongoClientSettings_" data-uid="MongoDB.Entities.DB.AllDatabaseNamesAsync(MongoDB.Driver.MongoClientSettings)">AllDatabaseNamesAsync(MongoClientSettings)</h4>
  <div class="markdown level1 summary"><p>Gets a list of all database names from the server</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;IEnumerable&lt;string&gt;&gt; AllDatabaseNamesAsync(MongoClientSettings settings)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.MongoClientSettings</span></td>
        <td><span class="parametername">settings</span></td>
        <td><p>A MongoClientSettings object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Collections.Generic.IEnumerable</span>&lt;<span class="xref">System.String</span>&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_AllDatabaseNamesAsync_" data-uid="MongoDB.Entities.DB.AllDatabaseNamesAsync*"></a>
  <h4 id="MongoDB_Entities_DB_AllDatabaseNamesAsync_System_String_System_Int32_" data-uid="MongoDB.Entities.DB.AllDatabaseNamesAsync(System.String,System.Int32)">AllDatabaseNamesAsync(String, Int32)</h4>
  <div class="markdown level1 summary"><p>Gets a list of all database names from the server</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;IEnumerable&lt;string&gt;&gt; AllDatabaseNamesAsync(string host = &quot;127.0.0.1&quot;, int port = 27017)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">host</span></td>
        <td><p>Address of the MongoDB server</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">port</span></td>
        <td><p>Port number of the server</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Collections.Generic.IEnumerable</span>&lt;<span class="xref">System.String</span>&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_ChangeDefaultDatabase_" data-uid="MongoDB.Entities.DB.ChangeDefaultDatabase*"></a>
  <h4 id="MongoDB_Entities_DB_ChangeDefaultDatabase_System_String_" data-uid="MongoDB.Entities.DB.ChangeDefaultDatabase(System.String)">ChangeDefaultDatabase(String)</h4>
  <div class="markdown level1 summary"><p>Switches the default database at runtime</p>
<p>WARNING: Use at your own risk!!! Might result in entities getting saved in the wrong databases under high concurrency situations.</p>
<p>TIP: Make sure to cancel any watchers (change-streams) before switching the default database.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static void ChangeDefaultDatabase(string name)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">name</span></td>
        <td><p>The name of the database to mark as the new default database</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Collection_" data-uid="MongoDB.Entities.DB.Collection*"></a>
  <h4 id="MongoDB_Entities_DB_Collection__1" data-uid="MongoDB.Entities.DB.Collection``1">Collection&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Gets the IMongoCollection for a given IEntity type.</p>
<p>TIP: Try never to use this unless really necessary.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IMongoCollection&lt;T&gt; Collection&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IMongoCollection</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CollectionName_" data-uid="MongoDB.Entities.DB.CollectionName*"></a>
  <h4 id="MongoDB_Entities_DB_CollectionName__1" data-uid="MongoDB.Entities.DB.CollectionName``1">CollectionName&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Gets the collection name for a given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static string CollectionName&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The type of entity to get the collection name for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CountAsync_" data-uid="MongoDB.Entities.DB.CountAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CountAsync__1_MongoDB_Driver_FilterDefinition___0__MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_CountOptions_" data-uid="MongoDB.Entities.DB.CountAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.CountOptions)">CountAsync&lt;T&gt;(FilterDefinition&lt;T&gt;, IClientSessionHandle, CancellationToken, CountOptions)</h4>
  <div class="markdown level1 summary"><p>Gets an accurate count of how many total entities are in the collection for a given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;long&gt; CountAsync&lt;T&gt;(FilterDefinition&lt;T&gt; filter, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), CountOptions options = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.FilterDefinition</span>&lt;T&gt;</td>
        <td><span class="parametername">filter</span></td>
        <td><p>A filter definition</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.CountOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>An optional CountOptions object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Int64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the count for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CountAsync_" data-uid="MongoDB.Entities.DB.CountAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CountAsync__1_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.CountAsync``1(MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">CountAsync&lt;T&gt;(IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Gets an accurate count of how many total entities are in the collection for a given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;long&gt; CountAsync&lt;T&gt;(IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Int64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the count for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CountAsync_" data-uid="MongoDB.Entities.DB.CountAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CountAsync__1_System_Func_MongoDB_Driver_FilterDefinitionBuilder___0__MongoDB_Driver_FilterDefinition___0___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_CountOptions_" data-uid="MongoDB.Entities.DB.CountAsync``1(System.Func{MongoDB.Driver.FilterDefinitionBuilder{``0},MongoDB.Driver.FilterDefinition{``0}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.CountOptions)">CountAsync&lt;T&gt;(Func&lt;FilterDefinitionBuilder&lt;T&gt;, FilterDefinition&lt;T&gt;&gt;, IClientSessionHandle, CancellationToken, CountOptions)</h4>
  <div class="markdown level1 summary"><p>Gets an accurate count of how many total entities are in the collection for a given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;long&gt; CountAsync&lt;T&gt;(Func&lt;FilterDefinitionBuilder&lt;T&gt;, FilterDefinition&lt;T&gt;&gt; filter, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), CountOptions options = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Func</span>&lt;<span class="xref">MongoDB.Driver.FilterDefinitionBuilder</span>&lt;T&gt;, <span class="xref">MongoDB.Driver.FilterDefinition</span>&lt;T&gt;&gt;</td>
        <td><span class="parametername">filter</span></td>
        <td><p>f =&gt; f.Eq(x =&gt; x.Prop, Value) &amp; f.Gt(x =&gt; x.Prop, Value)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.CountOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>An optional CountOptions object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Int64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the count for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CountAsync_" data-uid="MongoDB.Entities.DB.CountAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CountAsync__1_System_Linq_Expressions_Expression_System_Func___0_System_Boolean___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_CountOptions_" data-uid="MongoDB.Entities.DB.CountAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.CountOptions)">CountAsync&lt;T&gt;(Expression&lt;Func&lt;T, Boolean&gt;&gt;, IClientSessionHandle, CancellationToken, CountOptions)</h4>
  <div class="markdown level1 summary"><p>Gets an accurate count of how many entities are matched for a given expression/filter</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;long&gt; CountAsync&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; expression, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), CountOptions options = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Boolean</span>&gt;&gt;</td>
        <td><span class="parametername">expression</span></td>
        <td><p>A lambda expression for getting the count for a subset of the data</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.CountOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>An optional CountOptions object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Int64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the count for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CountEstimatedAsync_" data-uid="MongoDB.Entities.DB.CountEstimatedAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CountEstimatedAsync__1_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.CountEstimatedAsync``1(System.Threading.CancellationToken)">CountEstimatedAsync&lt;T&gt;(CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Gets a fast estimation of how many documents are in the collection using metadata.</p>
<p>HINT: The estimation may not be exactly accurate.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;long&gt; CountEstimatedAsync&lt;T&gt;(CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Int64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the count for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_CreateCollectionAsync_" data-uid="MongoDB.Entities.DB.CreateCollectionAsync*"></a>
  <h4 id="MongoDB_Entities_DB_CreateCollectionAsync__1_System_Action_MongoDB_Driver_CreateCollectionOptions___0___System_Threading_CancellationToken_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.CreateCollectionAsync``1(System.Action{MongoDB.Driver.CreateCollectionOptions{``0}},System.Threading.CancellationToken,MongoDB.Driver.IClientSessionHandle)">CreateCollectionAsync&lt;T&gt;(Action&lt;CreateCollectionOptions&lt;T&gt;&gt;, CancellationToken, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Creates a collection for an Entity type explicitly using the given options</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task CreateCollectionAsync&lt;T&gt;(Action&lt;CreateCollectionOptions&lt;T&gt;&gt; options, CancellationToken cancellation = default(CancellationToken), IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Action</span>&lt;<span class="xref">MongoDB.Driver.CreateCollectionOptions</span>&lt;T&gt;&gt;</td>
        <td><span class="parametername">options</span></td>
        <td><p>The options to use for collection creation</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The type of entity that will be stored in the created collection</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Database_" data-uid="MongoDB.Entities.DB.Database*"></a>
  <h4 id="MongoDB_Entities_DB_Database_System_String_" data-uid="MongoDB.Entities.DB.Database(System.String)">Database(String)</h4>
  <div class="markdown level1 summary"><p>Gets the IMongoDatabase for a given database name if it has been previously initialized.
You can also get the default database by passing 'default' or 'null' for the name parameter.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IMongoDatabase Database(string name)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">name</span></td>
        <td><p>The name of the database to retrieve</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IMongoDatabase</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Database_" data-uid="MongoDB.Entities.DB.Database*"></a>
  <h4 id="MongoDB_Entities_DB_Database__1" data-uid="MongoDB.Entities.DB.Database``1">Database&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Gets the IMongoDatabase for the given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IMongoDatabase Database&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IMongoDatabase</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The type of entity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DatabaseFor_" data-uid="MongoDB.Entities.DB.DatabaseFor*"></a>
  <h4 id="MongoDB_Entities_DB_DatabaseFor__1_System_String_" data-uid="MongoDB.Entities.DB.DatabaseFor``1(System.String)">DatabaseFor&lt;T&gt;(String)</h4>
  <div class="markdown level1 summary"><p>Specifies the database that a given entity type should be stored in.
Only needed for entity types you want stored in a db other than the default db.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static void DatabaseFor&lt;T&gt;(string database)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">database</span></td>
        <td><p>The name of the database</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DatabaseName_" data-uid="MongoDB.Entities.DB.DatabaseName*"></a>
  <h4 id="MongoDB_Entities_DB_DatabaseName__1" data-uid="MongoDB.Entities.DB.DatabaseName``1">DatabaseName&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Gets the name of the database a given entity type is attached to. Returns name of default database if not specifically attached.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static string DatabaseName&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DeleteAsync_" data-uid="MongoDB.Entities.DB.DeleteAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DeleteAsync__1_MongoDB_Driver_FilterDefinition___0__MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_Collation_" data-uid="MongoDB.Entities.DB.DeleteAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.Collation)">DeleteAsync&lt;T&gt;(FilterDefinition&lt;T&gt;, IClientSessionHandle, CancellationToken, Collation)</h4>
  <div class="markdown level1 summary"><p>Deletes matching entities with a filter definition</p>
<p>HINT: If the expression matches more than 100,000 entities, they will be deleted in batches of 100k.</p>
<p>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;DeleteResult&gt; DeleteAsync&lt;T&gt;(FilterDefinition&lt;T&gt; filter, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), Collation collation = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.FilterDefinition</span>&lt;T&gt;</td>
        <td><span class="parametername">filter</span></td>
        <td><p>A filter definition for matching entities to delete.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.Collation</span></td>
        <td><span class="parametername">collation</span></td>
        <td><p>An optional collation object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.DeleteResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DeleteAsync_" data-uid="MongoDB.Entities.DB.DeleteAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DeleteAsync__1_System_Collections_Generic_IEnumerable_System_String__MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.DeleteAsync``1(System.Collections.Generic.IEnumerable{System.String},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">DeleteAsync&lt;T&gt;(IEnumerable&lt;String&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Deletes entities using a collection of IDs</p>
<p>HINT: If more than 100,000 IDs are passed in, they will be processed in batches of 100k.</p>
<p>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;DeleteResult&gt; DeleteAsync&lt;T&gt;(IEnumerable&lt;string&gt; IDs, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;<span class="xref">System.String</span>&gt;</td>
        <td><span class="parametername">IDs</span></td>
        <td><p>An IEnumerable of entity IDs</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.DeleteResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DeleteAsync_" data-uid="MongoDB.Entities.DB.DeleteAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DeleteAsync__1_System_Func_MongoDB_Driver_FilterDefinitionBuilder___0__MongoDB_Driver_FilterDefinition___0___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_Collation_" data-uid="MongoDB.Entities.DB.DeleteAsync``1(System.Func{MongoDB.Driver.FilterDefinitionBuilder{``0},MongoDB.Driver.FilterDefinition{``0}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.Collation)">DeleteAsync&lt;T&gt;(Func&lt;FilterDefinitionBuilder&lt;T&gt;, FilterDefinition&lt;T&gt;&gt;, IClientSessionHandle, CancellationToken, Collation)</h4>
  <div class="markdown level1 summary"><p>Deletes matching entities with a filter expression</p>
<p>HINT: If the expression matches more than 100,000 entities, they will be deleted in batches of 100k.</p>
<p>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;DeleteResult&gt; DeleteAsync&lt;T&gt;(Func&lt;FilterDefinitionBuilder&lt;T&gt;, FilterDefinition&lt;T&gt;&gt; filter, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), Collation collation = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Func</span>&lt;<span class="xref">MongoDB.Driver.FilterDefinitionBuilder</span>&lt;T&gt;, <span class="xref">MongoDB.Driver.FilterDefinition</span>&lt;T&gt;&gt;</td>
        <td><span class="parametername">filter</span></td>
        <td><p>f =&gt; f.Eq(x =&gt; x.Prop, Value) &amp; f.Gt(x =&gt; x.Prop, Value)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.Collation</span></td>
        <td><span class="parametername">collation</span></td>
        <td><p>An optional collation object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.DeleteResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DeleteAsync_" data-uid="MongoDB.Entities.DB.DeleteAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DeleteAsync__1_System_Linq_Expressions_Expression_System_Func___0_System_Boolean___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_MongoDB_Driver_Collation_" data-uid="MongoDB.Entities.DB.DeleteAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken,MongoDB.Driver.Collation)">DeleteAsync&lt;T&gt;(Expression&lt;Func&lt;T, Boolean&gt;&gt;, IClientSessionHandle, CancellationToken, Collation)</h4>
  <div class="markdown level1 summary"><p>Deletes matching entities with an expression</p>
<p>HINT: If the expression matches more than 100,000 entities, they will be deleted in batches of 100k.</p>
<p>HINT: If these entities are referenced by one-to-many/many-to-many relationships, those references are also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;DeleteResult&gt; DeleteAsync&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; expression, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken), Collation collation = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Boolean</span>&gt;&gt;</td>
        <td><span class="parametername">expression</span></td>
        <td><p>A lambda expression for matching entities to delete.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.Collation</span></td>
        <td><span class="parametername">collation</span></td>
        <td><p>An optional collation object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.DeleteResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DeleteAsync_" data-uid="MongoDB.Entities.DB.DeleteAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DeleteAsync__1_System_String_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.DeleteAsync``1(System.String,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">DeleteAsync&lt;T&gt;(String, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Deletes a single entity from MongoDB.</p>
<p>HINT: If this entity is referenced by one-to-many/many-to-many relationships, those references are also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;DeleteResult&gt; DeleteAsync&lt;T&gt;(string ID, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">ID</span></td>
        <td><p>The Id of the entity to delete</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.DeleteResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Distinct_" data-uid="MongoDB.Entities.DB.Distinct*"></a>
  <h4 id="MongoDB_Entities_DB_Distinct__2_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Distinct``2(MongoDB.Driver.IClientSessionHandle)">Distinct&lt;T, TProperty&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents a MongoDB Distinct command where you can get back distinct values for a given property of a given Entity.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Distinct&lt;T, TProperty&gt; Distinct&lt;T, TProperty&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Distinct-2.html">Distinct</a>&lt;T, TProperty&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any Entity that implements IEntity interface</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TProperty</span></td>
        <td><p>The type of the property of the entity you'd like to get unique values for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_DropCollectionAsync_" data-uid="MongoDB.Entities.DB.DropCollectionAsync*"></a>
  <h4 id="MongoDB_Entities_DB_DropCollectionAsync__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.DropCollectionAsync``1(MongoDB.Driver.IClientSessionHandle)">DropCollectionAsync&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Deletes the collection of a given entity type as well as the join collections for that entity.</p>
<p>TIP: When deleting a collection, all relationships associated with that entity type is also deleted.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task DropCollectionAsync&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to drop the collection of</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Entity_" data-uid="MongoDB.Entities.DB.Entity*"></a>
  <h4 id="MongoDB_Entities_DB_Entity__1" data-uid="MongoDB.Entities.DB.Entity``1">Entity&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Returns a new instance of the supplied IEntity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T Entity&lt;T&gt;()

    where T : IEntity, new()</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Entity_" data-uid="MongoDB.Entities.DB.Entity*"></a>
  <h4 id="MongoDB_Entities_DB_Entity__1_System_String_" data-uid="MongoDB.Entities.DB.Entity``1(System.String)">Entity&lt;T&gt;(String)</h4>
  <div class="markdown level1 summary"><p>Returns a new instance of the supplied IEntity type with the ID set to the supplied value</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T Entity&lt;T&gt;(string ID)

    where T : IEntity, new()</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">ID</span></td>
        <td><p>The ID to set on the returned instance</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_File_" data-uid="MongoDB.Entities.DB.File*"></a>
  <h4 id="MongoDB_Entities_DB_File__1_System_String_" data-uid="MongoDB.Entities.DB.File``1(System.String)">File&lt;T&gt;(String)</h4>
  <div class="markdown level1 summary"><p>Returns a DataStreamer object to enable uploading/downloading file data directly by supplying the ID of the file entity</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static DataStreamer File&lt;T&gt;(string ID)

    where T : FileEntity, new()</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">ID</span></td>
        <td><p>The ID of the file entity</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.DataStreamer.html">DataStreamer</a></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The file entity type</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Filter_" data-uid="MongoDB.Entities.DB.Filter*"></a>
  <h4 id="MongoDB_Entities_DB_Filter__1" data-uid="MongoDB.Entities.DB.Filter``1">Filter&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Exposes the mongodb Filter Definition Builder for a given type.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static FilterDefinitionBuilder&lt;T&gt; Filter&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.FilterDefinitionBuilder</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Find_" data-uid="MongoDB.Entities.DB.Find*"></a>
  <h4 id="MongoDB_Entities_DB_Find__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Find``1(MongoDB.Driver.IClientSessionHandle)">Find&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents a MongoDB Find command</p>
<p>TIP: Specify your criteria using .Match() .Sort() .Skip() .Take() .Project() .Option() methods and finally call .Execute()</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Find&lt;T&gt; Find&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Find-1.html">Find</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Find_" data-uid="MongoDB.Entities.DB.Find*"></a>
  <h4 id="MongoDB_Entities_DB_Find__2_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Find``2(MongoDB.Driver.IClientSessionHandle)">Find&lt;T, TProjection&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents a MongoDB Find command</p>
<p>TIP: Specify your criteria using .Match() .Sort() .Skip() .Take() .Project() .Option() methods and finally call .Execute()</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Find&lt;T, TProjection&gt; Find&lt;T, TProjection&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Find-2.html">Find</a>&lt;T, TProjection&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TProjection</span></td>
        <td><p>The type that is returned by projection</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Fluent_" data-uid="MongoDB.Entities.DB.Fluent*"></a>
  <h4 id="MongoDB_Entities_DB_Fluent__1_MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Fluent``1(MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle)">Fluent&lt;T&gt;(AggregateOptions, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Exposes the MongoDB collection for the given IEntity as an IAggregateFluent in order to facilitate Fluent queries.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IAggregateFluent&lt;T&gt; Fluent&lt;T&gt;(AggregateOptions options = null, IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IAggregateFluent</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_FluentGeoNear_" data-uid="MongoDB.Entities.DB.FluentGeoNear*"></a>
  <h4 id="MongoDB_Entities_DB_FluentGeoNear__1_MongoDB_Entities_Coordinates2D_System_Linq_Expressions_Expression_System_Func___0_System_Object___System_Boolean_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Int32__MongoDB_Bson_BsonDocument_System_Nullable_System_Double__System_Linq_Expressions_Expression_System_Func___0_System_Object___System_String_MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.FluentGeoNear``1(MongoDB.Entities.Coordinates2D,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.Boolean,System.Nullable{System.Double},System.Nullable{System.Double},System.Nullable{System.Int32},MongoDB.Bson.BsonDocument,System.Nullable{System.Double},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String,MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle)">FluentGeoNear&lt;T&gt;(Coordinates2D, Expression&lt;Func&lt;T, Object&gt;&gt;, Boolean, Nullable&lt;Double&gt;, Nullable&lt;Double&gt;, Nullable&lt;Int32&gt;, BsonDocument, Nullable&lt;Double&gt;, Expression&lt;Func&lt;T, Object&gt;&gt;, String, AggregateOptions, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Start a fluent aggregation pipeline with a $GeoNear stage with the supplied parameters.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IAggregateFluent&lt;T&gt; FluentGeoNear&lt;T&gt;(Coordinates2D NearCoordinates, Expression&lt;Func&lt;T, object&gt;&gt; DistanceField, bool Spherical = true, double? MaxDistance = null, double? MinDistance = null, int? Limit = null, BsonDocument Query = null, double? DistanceMultiplier = null, Expression&lt;Func&lt;T, object&gt;&gt; IncludeLocations = null, string IndexKey = null, AggregateOptions options = null, IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Coordinates2D.html">Coordinates2D</a></td>
        <td><span class="parametername">NearCoordinates</span></td>
        <td><p>The coordinates from which to find documents from</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">DistanceField</span></td>
        <td><p>x =&gt; x.Distance</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">Spherical</span></td>
        <td><p>Calculate distances using spherical geometry or not</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Double</span>&gt;</td>
        <td><span class="parametername">MaxDistance</span></td>
        <td><p>The maximum distance in meters from the center point that the documents can be</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Double</span>&gt;</td>
        <td><span class="parametername">MinDistance</span></td>
        <td><p>The minimum distance in meters from the center point that the documents can be</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Int32</span>&gt;</td>
        <td><span class="parametername">Limit</span></td>
        <td><p>The maximum number of documents to return</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Bson.BsonDocument</span></td>
        <td><span class="parametername">Query</span></td>
        <td><p>Limits the results to the documents that match the query</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Nullable</span>&lt;<span class="xref">System.Double</span>&gt;</td>
        <td><span class="parametername">DistanceMultiplier</span></td>
        <td><p>The factor to multiply all distances returned by the query</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">IncludeLocations</span></td>
        <td><p>Specify the output field to store the point used to calculate the distance</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">IndexKey</span></td>
        <td></td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IAggregateFluent</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_FluentTextSearch_" data-uid="MongoDB.Entities.DB.FluentTextSearch*"></a>
  <h4 id="MongoDB_Entities_DB_FluentTextSearch__1_MongoDB_Entities_Search_System_String_System_Boolean_System_Boolean_System_String_MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.FluentTextSearch``1(MongoDB.Entities.Search,System.String,System.Boolean,System.Boolean,System.String,MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle)">FluentTextSearch&lt;T&gt;(Search, String, Boolean, Boolean, String, AggregateOptions, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Start a fluent aggregation pipeline with a $text stage with the supplied parameters.</p>
<p>TIP: Make sure to define a text index with DB.Index&lt;T>() before searching</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IAggregateFluent&lt;T&gt; FluentTextSearch&lt;T&gt;(Search searchType, string searchTerm, bool caseSensitive = false, bool diacriticSensitive = false, string language = null, AggregateOptions options = null, IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Search.html">Search</a></td>
        <td><span class="parametername">searchType</span></td>
        <td><p>The type of text matching to do</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">searchTerm</span></td>
        <td><p>The search term</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">caseSensitive</span></td>
        <td><p>Case sensitivity of the search (optional)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Boolean</span></td>
        <td><span class="parametername">diacriticSensitive</span></td>
        <td><p>Diacritic sensitivity of the search (optional)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">language</span></td>
        <td><p>The language for the search (optional)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>Options for finding documents (not required)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IAggregateFluent</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Index_" data-uid="MongoDB.Entities.DB.Index*"></a>
  <h4 id="MongoDB_Entities_DB_Index__1" data-uid="MongoDB.Entities.DB.Index``1">Index&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Represents an index for a given IEntity</p>
<p>TIP: Define the keys first with .Key() method and finally call the .Create() method.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Index&lt;T&gt; Index&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Index-1.html">Index</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_InitAsync_" data-uid="MongoDB.Entities.DB.InitAsync*"></a>
  <h4 id="MongoDB_Entities_DB_InitAsync_System_String_MongoDB_Driver_MongoClientSettings_" data-uid="MongoDB.Entities.DB.InitAsync(System.String,MongoDB.Driver.MongoClientSettings)">InitAsync(String, MongoClientSettings)</h4>
  <div class="markdown level1 summary"><p>Initializes a MongoDB connection with the given connection parameters.</p>
<p>WARNING: will throw an error if server is not reachable!</p>
You can call this method as many times as you want (such as in serverless functions) with the same parameters and the connections won&apos;t get duplicated.
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task InitAsync(string database, MongoClientSettings settings)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">database</span></td>
        <td><p>Name of the database</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.MongoClientSettings</span></td>
        <td><span class="parametername">settings</span></td>
        <td><p>A MongoClientSettings object</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_InitAsync_" data-uid="MongoDB.Entities.DB.InitAsync*"></a>
  <h4 id="MongoDB_Entities_DB_InitAsync_System_String_System_String_System_Int32_" data-uid="MongoDB.Entities.DB.InitAsync(System.String,System.String,System.Int32)">InitAsync(String, String, Int32)</h4>
  <div class="markdown level1 summary"><p>Initializes a MongoDB connection with the given connection parameters.</p>
<p>WARNING: will throw an error if server is not reachable!</p>
You can call this method as many times as you want (such as in serverless functions) with the same parameters and the connections won&apos;t get duplicated.
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task InitAsync(string database, string host = &quot;127.0.0.1&quot;, int port = 27017)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">database</span></td>
        <td><p>Name of the database</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">host</span></td>
        <td><p>Address of the MongoDB server</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Int32</span></td>
        <td><span class="parametername">port</span></td>
        <td><p>Port number of the server</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_InsertAsync_" data-uid="MongoDB.Entities.DB.InsertAsync*"></a>
  <h4 id="MongoDB_Entities_DB_InsertAsync__1___0_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.InsertAsync``1(``0,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">InsertAsync&lt;T&gt;(T, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Inserts a new entity into the colleciton.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task InsertAsync&lt;T&gt;(T entity, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td><span class="parametername">entity</span></td>
        <td><p>The instance to persist</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>And optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_InsertAsync_" data-uid="MongoDB.Entities.DB.InsertAsync*"></a>
  <h4 id="MongoDB_Entities_DB_InsertAsync__1_System_Collections_Generic_IEnumerable___0__MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.InsertAsync``1(System.Collections.Generic.IEnumerable{``0},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">InsertAsync&lt;T&gt;(IEnumerable&lt;T&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Inserts a batch of new entities into the collection.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;BulkWriteResult&lt;T&gt;&gt; InsertAsync&lt;T&gt;(IEnumerable&lt;T&gt; entities, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;T&gt;</td>
        <td><span class="parametername">entities</span></td>
        <td><p>The entities to persist</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>And optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.BulkWriteResult</span>&lt;T&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_MigrateAsync_" data-uid="MongoDB.Entities.DB.MigrateAsync*"></a>
  <h4 id="MongoDB_Entities_DB_MigrateAsync" data-uid="MongoDB.Entities.DB.MigrateAsync">MigrateAsync()</h4>
  <div class="markdown level1 summary"><p>Executes migration classes that implement the IMigration interface in the correct order to transform the database.</p>
<p>TIP: Write classes with names such as: _001_rename_a_field.cs, _002_delete_a_field.cs, etc. 
and implement IMigration interface on them. 
Call this method at the startup of the application in order to run the migrations.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task MigrateAsync()</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_MigrateAsync_" data-uid="MongoDB.Entities.DB.MigrateAsync*"></a>
  <h4 id="MongoDB_Entities_DB_MigrateAsync__1" data-uid="MongoDB.Entities.DB.MigrateAsync``1">MigrateAsync&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Discover and run migrations from the same assembly as the specified type.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task MigrateAsync&lt;T&gt;()

    where T : class</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>A type that is from the same assembly as the migrations you want to run</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_MigrationsAsync_" data-uid="MongoDB.Entities.DB.MigrationsAsync*"></a>
  <h4 id="MongoDB_Entities_DB_MigrationsAsync_System_Collections_Generic_IEnumerable_MongoDB_Entities_IMigration__" data-uid="MongoDB.Entities.DB.MigrationsAsync(System.Collections.Generic.IEnumerable{MongoDB.Entities.IMigration})">MigrationsAsync(IEnumerable&lt;IMigration&gt;)</h4>
  <div class="markdown level1 summary"><p>Executes the given collection of IMigrations in the correct order to transform the database.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task MigrationsAsync(IEnumerable&lt;IMigration&gt; migrations)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;<a class="xref" href="MongoDB.Entities.IMigration.html">IMigration</a>&gt;</td>
        <td><span class="parametername">migrations</span></td>
        <td><p>The collection of migrations to execute</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_NextSequentialNumberAsync_" data-uid="MongoDB.Entities.DB.NextSequentialNumberAsync*"></a>
  <h4 id="MongoDB_Entities_DB_NextSequentialNumberAsync_System_String_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.NextSequentialNumberAsync(System.String,System.Threading.CancellationToken)">NextSequentialNumberAsync(String, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Returns an atomically generated sequential number for the given sequence name everytime the method is called</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;ulong&gt; NextSequentialNumberAsync(string sequenceName, CancellationToken cancellation = default(CancellationToken))</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">sequenceName</span></td>
        <td><p>The name of the sequence to get the next number for</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.UInt64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_NextSequentialNumberAsync_" data-uid="MongoDB.Entities.DB.NextSequentialNumberAsync*"></a>
  <h4 id="MongoDB_Entities_DB_NextSequentialNumberAsync__1_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.NextSequentialNumberAsync``1(System.Threading.CancellationToken)">NextSequentialNumberAsync&lt;T&gt;(CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Returns an atomically generated sequential number for the given Entity type everytime the method is called</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;ulong&gt; NextSequentialNumberAsync&lt;T&gt;(CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.UInt64</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The type of entity to get the next sequential number for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PagedSearch_" data-uid="MongoDB.Entities.DB.PagedSearch*"></a>
  <h4 id="MongoDB_Entities_DB_PagedSearch__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.PagedSearch``1(MongoDB.Driver.IClientSessionHandle)">PagedSearch&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents an aggregation query that retrieves results with easy paging support.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static PagedSearch&lt;T&gt; PagedSearch&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.PagedSearch-1.html">PagedSearch</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PagedSearch_" data-uid="MongoDB.Entities.DB.PagedSearch*"></a>
  <h4 id="MongoDB_Entities_DB_PagedSearch__2_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.PagedSearch``2(MongoDB.Driver.IClientSessionHandle)">PagedSearch&lt;T, TProjection&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents an aggregation query that retrieves results with easy paging support.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static PagedSearch&lt;T, TProjection&gt; PagedSearch&lt;T, TProjection&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.PagedSearch-2.html">PagedSearch</a>&lt;T, TProjection&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TProjection</span></td>
        <td><p>The type you'd like to project the results to.</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PipelineAsync_" data-uid="MongoDB.Entities.DB.PipelineAsync*"></a>
  <h4 id="MongoDB_Entities_DB_PipelineAsync__2_MongoDB_Entities_Template___0___1__MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.PipelineAsync``2(MongoDB.Entities.Template{``0,``1},MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">PipelineAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt;, AggregateOptions, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Executes an aggregation pipeline by supplying a 'Template' object and get a list of results</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;List&lt;TResult&gt;&gt; PipelineAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt; template, AggregateOptions options = null, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Template-2.html">Template</a>&lt;T, TResult&gt;</td>
        <td><span class="parametername">template</span></td>
        <td><p>A 'Template' object with tags replaced</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">System.Collections.Generic.List</span>&lt;TResult&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TResult</span></td>
        <td><p>The type of the resulting objects</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PipelineCursorAsync_" data-uid="MongoDB.Entities.DB.PipelineCursorAsync*"></a>
  <h4 id="MongoDB_Entities_DB_PipelineCursorAsync__2_MongoDB_Entities_Template___0___1__MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.PipelineCursorAsync``2(MongoDB.Entities.Template{``0,``1},MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">PipelineCursorAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt;, AggregateOptions, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Executes an aggregation pipeline by supplying a 'Template' object and returns a cursor</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;IAsyncCursor&lt;TResult&gt;&gt; PipelineCursorAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt; template, AggregateOptions options = null, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Template-2.html">Template</a>&lt;T, TResult&gt;</td>
        <td><span class="parametername">template</span></td>
        <td><p>A 'Template' object with tags replaced</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.IAsyncCursor</span>&lt;TResult&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TResult</span></td>
        <td><p>The type of the resulting objects</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PipelineFirstAsync_" data-uid="MongoDB.Entities.DB.PipelineFirstAsync*"></a>
  <h4 id="MongoDB_Entities_DB_PipelineFirstAsync__2_MongoDB_Entities_Template___0___1__MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.PipelineFirstAsync``2(MongoDB.Entities.Template{``0,``1},MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">PipelineFirstAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt;, AggregateOptions, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Executes an aggregation pipeline by supplying a 'Template' object and get the first result or default value if not found.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;TResult&gt; PipelineFirstAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt; template, AggregateOptions options = null, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Template-2.html">Template</a>&lt;T, TResult&gt;</td>
        <td><span class="parametername">template</span></td>
        <td><p>A 'Template' object with tags replaced</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;TResult&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TResult</span></td>
        <td><p>The type of the resulting object</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_PipelineSingleAsync_" data-uid="MongoDB.Entities.DB.PipelineSingleAsync*"></a>
  <h4 id="MongoDB_Entities_DB_PipelineSingleAsync__2_MongoDB_Entities_Template___0___1__MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.PipelineSingleAsync``2(MongoDB.Entities.Template{``0,``1},MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">PipelineSingleAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt;, AggregateOptions, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Executes an aggregation pipeline by supplying a 'Template' object and get a single result or default value if not found.
If more than one entity is found, it will throw an exception.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static async Task&lt;TResult&gt; PipelineSingleAsync&lt;T, TResult&gt;(Template&lt;T, TResult&gt; template, AggregateOptions options = null, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Template-2.html">Template</a>&lt;T, TResult&gt;</td>
        <td><span class="parametername">template</span></td>
        <td><p>A 'Template' object with tags replaced</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The options for the aggregation. This is not required.</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;TResult&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TResult</span></td>
        <td><p>The type of the resulting object</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Projection_" data-uid="MongoDB.Entities.DB.Projection*"></a>
  <h4 id="MongoDB_Entities_DB_Projection__1" data-uid="MongoDB.Entities.DB.Projection``1">Projection&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Exposes the mongodb Projection Definition Builder for a given type.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static ProjectionDefinitionBuilder&lt;T&gt; Projection&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.ProjectionDefinitionBuilder</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Queryable_" data-uid="MongoDB.Entities.DB.Queryable*"></a>
  <h4 id="MongoDB_Entities_DB_Queryable__1_MongoDB_Driver_AggregateOptions_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Queryable``1(MongoDB.Driver.AggregateOptions,MongoDB.Driver.IClientSessionHandle)">Queryable&lt;T&gt;(AggregateOptions, IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Exposes the MongoDB collection for the given IEntity as an IQueryable in order to facilitate LINQ queries.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IMongoQueryable&lt;T&gt; Queryable&lt;T&gt;(AggregateOptions options = null, IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.AggregateOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>The aggregate options</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if used within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.Linq.IMongoQueryable</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Replace_" data-uid="MongoDB.Entities.DB.Replace*"></a>
  <h4 id="MongoDB_Entities_DB_Replace__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Replace``1(MongoDB.Driver.IClientSessionHandle)">Replace&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents a ReplaceOne command, which can replace the first matched document with a given entity</p>
<p>TIP: Specify a filter first with the .Match(). Then set entity with .WithEntity() and finally call .Execute() to run the command.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Replace&lt;T&gt; Replace&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Replace-1.html">Replace</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveAsync_" data-uid="MongoDB.Entities.DB.SaveAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveAsync__1___0_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveAsync``1(``0,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveAsync&lt;T&gt;(T, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves a complete entity replacing an existing entity or creating a new one if it does not exist.
If ID value is null, a new entity is created. If ID has a value, then existing entity is replaced.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task SaveAsync&lt;T&gt;(T entity, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td><span class="parametername">entity</span></td>
        <td><p>The instance to persist</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>And optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveAsync_" data-uid="MongoDB.Entities.DB.SaveAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveAsync__1_System_Collections_Generic_IEnumerable___0__MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveAsync``1(System.Collections.Generic.IEnumerable{``0},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveAsync&lt;T&gt;(IEnumerable&lt;T&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves a batch of complete entities replacing existing ones or creating new ones if they do not exist.
If ID value is null, a new entity is created. If ID has a value, then existing entity is replaced.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;BulkWriteResult&lt;T&gt;&gt; SaveAsync&lt;T&gt;(IEnumerable&lt;T&gt; entities, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;T&gt;</td>
        <td><span class="parametername">entities</span></td>
        <td><p>The entities to persist</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>And optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.BulkWriteResult</span>&lt;T&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveExceptAsync_" data-uid="MongoDB.Entities.DB.SaveExceptAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveExceptAsync__1___0_System_Linq_Expressions_Expression_System_Func___0_System_Object___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveExceptAsync``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveExceptAsync&lt;T&gt;(T, Expression&lt;Func&lt;T, Object&gt;&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves an entity partially excluding the specified subset of properties.
If ID value is null, a new entity is created. If ID has a value, then existing entity is updated.</p>
<p>TIP: The properties to be excluded can be specified with a &apos;New&apos; expression. 
You can only specify root level properties with the expression.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;UpdateResult&gt; SaveExceptAsync&lt;T&gt;(T entity, Expression&lt;Func&lt;T, object&gt;&gt; members, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td><span class="parametername">entity</span></td>
        <td><p>The entity to save</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">members</span></td>
        <td><p>x =&gt; new { x.PropOne, x.PropTwo }</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.UpdateResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveExceptAsync_" data-uid="MongoDB.Entities.DB.SaveExceptAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveExceptAsync__1_System_Collections_Generic_IEnumerable___0__System_Linq_Expressions_Expression_System_Func___0_System_Object___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveExceptAsync``1(System.Collections.Generic.IEnumerable{``0},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveExceptAsync&lt;T&gt;(IEnumerable&lt;T&gt;, Expression&lt;Func&lt;T, Object&gt;&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves a batch of entities partially excluding the specified subset of properties.
If ID value is null, a new entity is created. If ID has a value, then existing entity is updated.</p>
<p>TIP: The properties to be excluded can be specified with a &apos;New&apos; expression. 
You can only specify root level properties with the expression.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;BulkWriteResult&lt;T&gt;&gt; SaveExceptAsync&lt;T&gt;(IEnumerable&lt;T&gt; entities, Expression&lt;Func&lt;T, object&gt;&gt; members, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;T&gt;</td>
        <td><span class="parametername">entities</span></td>
        <td><p>The batch of entities to save</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">members</span></td>
        <td><p>x =&gt; new { x.PropOne, x.PropTwo }</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.BulkWriteResult</span>&lt;T&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveOnlyAsync_" data-uid="MongoDB.Entities.DB.SaveOnlyAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveOnlyAsync__1___0_System_Linq_Expressions_Expression_System_Func___0_System_Object___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveOnlyAsync``1(``0,System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveOnlyAsync&lt;T&gt;(T, Expression&lt;Func&lt;T, Object&gt;&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves an entity partially with only the specified subset of properties.
If ID value is null, a new entity is created. If ID has a value, then existing entity is updated.</p>
<p>TIP: The properties to be saved can be specified with a &apos;New&apos; expression. 
You can only specify root level properties with the expression.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;UpdateResult&gt; SaveOnlyAsync&lt;T&gt;(T entity, Expression&lt;Func&lt;T, object&gt;&gt; members, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td><span class="parametername">entity</span></td>
        <td><p>The entity to save</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">members</span></td>
        <td><p>x =&gt; new { x.PropOne, x.PropTwo }</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.UpdateResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SaveOnlyAsync_" data-uid="MongoDB.Entities.DB.SaveOnlyAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SaveOnlyAsync__1_System_Collections_Generic_IEnumerable___0__System_Linq_Expressions_Expression_System_Func___0_System_Object___MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SaveOnlyAsync``1(System.Collections.Generic.IEnumerable{``0},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SaveOnlyAsync&lt;T&gt;(IEnumerable&lt;T&gt;, Expression&lt;Func&lt;T, Object&gt;&gt;, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves a batch of entities partially with only the specified subset of properties.
If ID value is null, a new entity is created. If ID has a value, then existing entity is updated.</p>
<p>TIP: The properties to be saved can be specified with a &apos;New&apos; expression. 
You can only specify root level properties with the expression.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;BulkWriteResult&lt;T&gt;&gt; SaveOnlyAsync&lt;T&gt;(IEnumerable&lt;T&gt; entities, Expression&lt;Func&lt;T, object&gt;&gt; members, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;T&gt;</td>
        <td><span class="parametername">entities</span></td>
        <td><p>The batch of entities to save</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Linq.Expressions.Expression</span>&lt;<span class="xref">System.Func</span>&lt;T, <span class="xref">System.Object</span>&gt;&gt;</td>
        <td><span class="parametername">members</span></td>
        <td><p>x =&gt; new { x.PropOne, x.PropTwo }</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.BulkWriteResult</span>&lt;T&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_SavePreservingAsync_" data-uid="MongoDB.Entities.DB.SavePreservingAsync*"></a>
  <h4 id="MongoDB_Entities_DB_SavePreservingAsync__1___0_MongoDB_Driver_IClientSessionHandle_System_Threading_CancellationToken_" data-uid="MongoDB.Entities.DB.SavePreservingAsync``1(``0,MongoDB.Driver.IClientSessionHandle,System.Threading.CancellationToken)">SavePreservingAsync&lt;T&gt;(T, IClientSessionHandle, CancellationToken)</h4>
  <div class="markdown level1 summary"><p>Saves an entity partially while excluding some properties.
The properties to be excluded can be specified using the [Preserve] or [DontPreserve] attributes.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Task&lt;UpdateResult&gt; SavePreservingAsync&lt;T&gt;(T entity, IClientSessionHandle session = null, CancellationToken cancellation = default(CancellationToken))

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">T</span></td>
        <td><span class="parametername">entity</span></td>
        <td><p>The entity to save</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">System.Threading.CancellationToken</span></td>
        <td><span class="parametername">cancellation</span></td>
        <td><p>An optional cancellation token</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Threading.Tasks.Task</span>&lt;<span class="xref">MongoDB.Driver.UpdateResult</span>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Sort_" data-uid="MongoDB.Entities.DB.Sort*"></a>
  <h4 id="MongoDB_Entities_DB_Sort__1" data-uid="MongoDB.Entities.DB.Sort``1">Sort&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Exposes the mongodb Sort Definition Builder for a given type.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static SortDefinitionBuilder&lt;T&gt; Sort&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.SortDefinitionBuilder</span>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Transaction_" data-uid="MongoDB.Entities.DB.Transaction*"></a>
  <h4 id="MongoDB_Entities_DB_Transaction_System_String_MongoDB_Driver_ClientSessionOptions_MongoDB_Entities_ModifiedBy_" data-uid="MongoDB.Entities.DB.Transaction(System.String,MongoDB.Driver.ClientSessionOptions,MongoDB.Entities.ModifiedBy)">Transaction(String, ClientSessionOptions, ModifiedBy)</h4>
  <div class="markdown level1 summary"><p>Gets a transaction context/scope for a given database or the default database if not specified.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Transaction Transaction(string database = null, ClientSessionOptions options = null, ModifiedBy modifiedBy = null)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">database</span></td>
        <td><p>The name of the database which this transaction is for (not required)</p>
</td>
      </tr>
      <tr>
        <td><span class="xref">MongoDB.Driver.ClientSessionOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>Client session options (not required)</p>
</td>
      </tr>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.ModifiedBy.html">ModifiedBy</a></td>
        <td><span class="parametername">modifiedBy</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Transaction.html">Transaction</a></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Transaction_" data-uid="MongoDB.Entities.DB.Transaction*"></a>
  <h4 id="MongoDB_Entities_DB_Transaction__1_MongoDB_Driver_ClientSessionOptions_MongoDB_Entities_ModifiedBy_" data-uid="MongoDB.Entities.DB.Transaction``1(MongoDB.Driver.ClientSessionOptions,MongoDB.Entities.ModifiedBy)">Transaction&lt;T&gt;(ClientSessionOptions, ModifiedBy)</h4>
  <div class="markdown level1 summary"><p>Gets a transaction context/scope for a given entity type's database</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Transaction Transaction&lt;T&gt;(ClientSessionOptions options = null, ModifiedBy modifiedBy = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.ClientSessionOptions</span></td>
        <td><span class="parametername">options</span></td>
        <td><p>Client session options (not required)</p>
</td>
      </tr>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.ModifiedBy.html">ModifiedBy</a></td>
        <td><span class="parametername">modifiedBy</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Transaction.html">Transaction</a></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to determine the database from for the transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Update_" data-uid="MongoDB.Entities.DB.Update*"></a>
  <h4 id="MongoDB_Entities_DB_Update__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.Update``1(MongoDB.Driver.IClientSessionHandle)">Update&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Represents an update command</p>
<p>TIP: Specify a filter first with the .Match() method. Then set property values with .Modify() and finally call .Execute() to run the command.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Update&lt;T&gt; Update&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Update-1.html">Update</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_UpdateAndGet_" data-uid="MongoDB.Entities.DB.UpdateAndGet*"></a>
  <h4 id="MongoDB_Entities_DB_UpdateAndGet__1_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.UpdateAndGet``1(MongoDB.Driver.IClientSessionHandle)">UpdateAndGet&lt;T&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Update and retrieve the first document that was updated.</p>
<p>TIP: Specify a filter first with the .Match(). Then set property values with .Modify() and finally call .Execute() to run the command.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static UpdateAndGet&lt;T&gt; UpdateAndGet&lt;T&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.UpdateAndGet-1.html">UpdateAndGet</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_UpdateAndGet_" data-uid="MongoDB.Entities.DB.UpdateAndGet*"></a>
  <h4 id="MongoDB_Entities_DB_UpdateAndGet__2_MongoDB_Driver_IClientSessionHandle_" data-uid="MongoDB.Entities.DB.UpdateAndGet``2(MongoDB.Driver.IClientSessionHandle)">UpdateAndGet&lt;T, TProjection&gt;(IClientSessionHandle)</h4>
  <div class="markdown level1 summary"><p>Update and retrieve the first document that was updated.</p>
<p>TIP: Specify a filter first with the .Match(). Then set property values with .Modify() and finally call .Execute() to run the command.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static UpdateAndGet&lt;T, TProjection&gt; UpdateAndGet&lt;T, TProjection&gt;(IClientSessionHandle session = null)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">MongoDB.Driver.IClientSessionHandle</span></td>
        <td><span class="parametername">session</span></td>
        <td><p>An optional session if using within a transaction</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.UpdateAndGet-2.html">UpdateAndGet</a>&lt;T, TProjection&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>Any class that implements IEntity</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TProjection</span></td>
        <td><p>The type to project to</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Watcher_" data-uid="MongoDB.Entities.DB.Watcher*"></a>
  <h4 id="MongoDB_Entities_DB_Watcher__1_System_String_" data-uid="MongoDB.Entities.DB.Watcher``1(System.String)">Watcher&lt;T&gt;(String)</h4>
  <div class="markdown level1 summary"><p>Retrieves the 'change-stream' watcher instance for a given unique name.
If an instance for the name does not exist, it will return a new instance.
If an instance already exists, that instance will be returned.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Watcher&lt;T&gt; Watcher&lt;T&gt;(string name)

    where T : IEntity</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">name</span></td>
        <td><p>A unique name for the watcher of this entity type. Names can be duplicate among different entity types.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="MongoDB.Entities.Watcher-1.html">Watcher</a>&lt;T&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get a watcher for</p>
</td>
      </tr>
    </tbody>
  </table>
  
  
  <a id="MongoDB_Entities_DB_Watchers_" data-uid="MongoDB.Entities.DB.Watchers*"></a>
  <h4 id="MongoDB_Entities_DB_Watchers__1" data-uid="MongoDB.Entities.DB.Watchers``1">Watchers&lt;T&gt;()</h4>
  <div class="markdown level1 summary"><p>Returns all the watchers for a given entity type</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="decalaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static IEnumerable&lt;Watcher&lt;T&gt;&gt; Watchers&lt;T&gt;()

    where T : IEntity</code></pre>
  </div>
  <h5 class="returns">Returns</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Generic.IEnumerable</span>&lt;<a class="xref" href="MongoDB.Entities.Watcher-1.html">Watcher</a>&lt;T&gt;&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The entity type to get the watcher of</p>
</td>
      </tr>
    </tbody>
  </table>
</article>
          </div>
          
          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
                <h5>In This Article</h5>
                <div></div>
              </nav>
            </div>
          </div>
        </div>
      </div>
      
      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
            Developed by <a href='https://github.com/dj-nitehawk'>Đĵ ΝιΓΞΗΛψΚ</a> and <a href='https://github.com/dj-nitehawk/MongoDB.Entities/graphs/contributors'>contributors</a> / Licensed under <a href='https://github.com/dj-nitehawk/MongoDB.Entities/blob/master/LICENSE'>MIT</a> / Website generated by <a href='https://dotnet.github.io/docfx/'>DocFX</a>
            
          </div>
        </div>
      </footer>
    </div>
    
    <script type="text/javascript" src="../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../styles/docfx.js"></script>
    <script type="text/javascript" src="../styles/main.js"></script>
  </body>
</html>
